﻿namespace C4F.DevKit.Bluetooth.ObjectPushProfile

{
    #region Using Directives
    using System;
    using System.ComponentModel;
    #endregion

    #region BusinessCardExchangeCompletedEventArgs

    /// <summary>
    /// EventArgs class to be used when a Business Card Exchange operation
    /// completes.
    /// </summary>
    public class BusinessCardExchangeCompletedEventArgs
        : AsyncCompletedEventArgs
    {
        #region Private Fields

        /// <summary>
        /// The name of the card that was pushed.
        /// </summary>
        private string localCardName;

        /// <summary>
        /// The name of the card that was pulled.
        /// </summary>
        private string remoteCardName;

        /// <summary>
        /// The card that was pulled.
        /// </summary>
        private byte[] remoteCardContents;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the name of the card that was pushed to the remote device.
        /// </summary>
        public string LocalCardName
        {
            get
            { return this.localCardName; }
        }

        /// <summary>
        /// Gets the name of the card that was pulled from the remote device.
        /// </summary>
        public string OutputCardName
        {
            get
            {
                RaiseExceptionIfNecessary();
                return this.remoteCardName;
            }
        }

        /// <summary>
        /// Gets the contents of the business card that was pulled from the
        /// remote device.
        /// </summary>
        public byte[] RemoteCardContents
        {
            get
            {
                RaiseExceptionIfNecessary();
                return this.remoteCardContents;
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes the BusinessCardExchangeCompletedEventArgs object.
        /// </summary>
        /// <param name="localCardName">The name of the card that was pushed to
        /// the remote device.</param>
        /// <param name="remoteCardName">The name of the card that was pulled
        /// from the remote device.</param>
        /// <param name="remoteCardContents">The byte stream of the card that 
        /// was pulled from the remote device.</param>
        /// <param name="error">An error that occurred during the asynchronous
        /// operation.</param>
        /// <param name="cancelled">A value indicating whether the asynchronous
        /// operation was cancelled.</param>
        /// <param name="userState">The user-supplied state object supplied 
        /// when the asynchronous operation was requested.</param>
        /// <exception cref="ArgumentNullException">localCardName or 
        /// remoteCardName is passed as an empty string or a null reference or
        /// remoteCardContents is passed as a null reference.</exception>
        public BusinessCardExchangeCompletedEventArgs(string localCardName,
                string remoteCardName, byte[] remoteCardContents,
                Exception error, bool cancelled, object userState)
            : base(error, cancelled, userState)
        {
            if (string.IsNullOrEmpty(localCardName))
                throw new ArgumentNullException("localCardName");

            if (remoteCardName == null)
                throw new ArgumentNullException("remoteCardName");

            if (remoteCardContents == null)
                throw new ArgumentNullException("remoteCardContents");

            this.localCardName = localCardName;
            this.remoteCardName = remoteCardName;
            this.remoteCardContents = remoteCardContents;
        }

        #endregion
    }
     #endregion
}